package star.trek.voyager.module.benz;

import star.trek.voyager.blueprint.axletree_socket.AxletreeSocket;
import star.trek.voyager.blueprint.car.Car;
import star.trek.voyager.blueprint.etasocket.ETASocket;
import star.trek.voyager.blueprint.status.Status;
import star.trek.voyager.module.benz.axletree_amg.AMGAxletree;
import star.trek.voyager.module.benz.car_sls_amg.BenzSlsAmg;
import star.trek.voyager.module.benz.engine_v8.EngineV8;
import star.trek.voyager.module.benz.wheel_amg.AMGWheel;
import star.trek.voyager.module.common.etasocket_common.CommonETASocket;

public class BenzFactory {
	
	public static Car getBenzSlsAmg(){
		BenzSlsAmg car = new BenzSlsAmg();
		
		//instance wheels
		AMGWheel w0 = new AMGWheel();
		AMGWheel w1 = new AMGWheel();
		AMGWheel w2 = new AMGWheel();
		AMGWheel w3 = new AMGWheel();
		
		//instance axletree and install wheels
		AMGAxletree axletree = new AMGAxletree();
		axletree.socket(w0, "0");
		axletree.socket(w1, "1");
		axletree.socket(w2, "2");
		axletree.socket(w3, "3");
		//init axletree
		axletree.init();
		
		//instance commonETASocket and install axletree
		CommonETASocket commonETASocket = new CommonETASocket();
		commonETASocket.socket((AxletreeSocket)axletree);
		commonETASocket.socket((Status)axletree);
		
		//instance engine and install 
		EngineV8 v8 = new EngineV8();
		v8.socket((ETASocket)commonETASocket);
		v8.socket((Status)commonETASocket);
		//register engine StatusOutput
		v8.socket(car);
		//init engine
		v8.init();
		
		//install engine to car
		car.setEngine(v8);
		car.init();
		
		return car;
	}
	
	public static void testBenzSlsAmg(){
		Car benzSlsAmg = BenzFactory.getBenzSlsAmg();
		System.out.println("====instance benzSlsAmg ok======");
		
		System.out.println(benzSlsAmg.getStatus());
		System.out.println("==========");
		benzSlsAmg.start();
		System.out.println(benzSlsAmg.getStatus());
//		System.out.println("==========");
//		benzSlsAmg.stop();
//		System.out.println(benzSlsAmg.getStatus());
//		System.out.println("==========");
	}
	

	/**
	 * @param args
	 */
	public static void main(String[] args){
		testBenzSlsAmg();
	}

}
